<?php

include_once('../@base/portal.php');
include_once('../login/login.php');

$user = $post->user;
$data = $post->data;
$login = login($user->number, $user->passwd);
if ($login['status'] == 0 && $login['userbase']['level'] > 0) {
  output(doSave($data));
} else {
  output(['status' => 1]);
}

function doSave($data)
{
  $sql = "UPDATE oprec_security_data SET clientOffice='{$data->clientOffice}', clientGroup='{$data->clientGroup}', clientRank='{$data->clientRank}', rank='{$data->rank}', passwd='{$data->passwd}', interest={$data->interest}, level={$data->level} WHERE number = $data->number";
  logfile('MODIFY_SECURITY_DATA', $sql);
  $result = exec_sql($sql);
  if ($result) {
    return [
      'status' => 0
    ];
  }
}

/*
UPDATE `oprec_security_data` SET `number`=[value-1],`name`=[value-2],`clientName`=[value-3],`clientOffice`=[value-4],`clientGroup`=[value-5],`clientRank`=[value-6],`passwd`=[value-7],`level`=[value-8] WHERE 1
*/